package controllers_student

import (
	"fmt"
	"github.com/astaxie/beego"
)

//结构化类型(struct)
type StudentController struct {
	beego.Controller
}

//定义返回结构体
type JSONS struct {
	//必须的大写开头
	Code string
	Msg  string
}

// 返回网页 并且带入数据  (重写MainController的Get方法)
func (c *StudentController) Get() {
	fmt.Println("asdsadasd")
	c.Data["Website"] = ".me"
	c.Data["Email"] = "astaxbeegoie@gmail.com"
	c.TplName = "index.tpl"
}

/**
获取路径参数
*/
func (this *StudentController) Details() {

	//获取 路径上定义的参数 比如  "/api/details/?:id"
	id := this.Ctx.Input.Param(":id")
	fmt.Println(id)
	fmt.Println("asdsadasd")
	this.TplName = "index.tpl"
}

/**
返回json数据
*/
func (this *StudentController) ListFood() {

	obj := JSONS{
		Code: "200",
		Msg:  "我是返回的数据哈哈哈哈",
	}
	this.Data["json"] = &obj
	this.ServeJSON()
}

func (this *StudentController) CreateFood() {
	fmt.Println("进来了啊")
	this.Ctx.WriteString("hello")
}

func (c *StudentController) UpdateFood() {
	c.TplName = "index.tpl"
}

func (c *StudentController) DeleteFood() {

}
